function Stats(log) {
	this.entries = log.entries.length;
	this.startTime = log.entries[0].time;
	this.endTime = log.entries[this.entries - 1].time;
	this.duration = (this.endTime.getTime() - this.startTime.getTime()) / 1000;
	this.totalDamage = 0;
	this.totalHeal = 0;
	this.spells = Array();
	this.healSpells = Array();
	for (i in log.entries) {
		var e = log.entries[i];
		if (e.value > 0) {	// Damage
			this.totalDamage += e.value;
			var spell;
			if (!this.spells[e.spell]) {
				spell = {};
				spell.count = 0;
				spell.totalDamage = 0;
				spell.max = -999999999;
				spell.min = +999999999;
				this.spells[e.spell] = spell;
			}
			else
				spell = this.spells[e.spell];

			spell.count++;
			spell.totalDamage += e.value;
			if (e.value < spell.min)
				spell.min = e.value;
			if (e.value > spell.max)
				spell.max = e.value;

		} else {	// Healing
			this.totalHeal -= e.value;
			var spell;
			if (!this.healSpells[e.spell]) {
				spell = {};
				spell.count = 0;
				spell.totalHealing = 0;
				spell.max = -999999999;
				spell.min = +999999999;
				this.healSpells[e.spell] = spell;
			}
			else
				spell = this.healSpells[e.spell];

			spell.count++;
			spell.totalHealing -= e.value;
			if (-e.value < spell.min)
				spell.min = -e.value;
			if (-e.value > spell.max)
				spell.max = -e.value;
		}
	}

	for (i in this.spells) {
		var spell = this.spells[i];
		spell.percentage = (spell.totalDamage / this.totalDamage) * 100;
	}

	for (i in this.healSpells) {
		var spell = this.healSpells[i];
		spell.percentage = (spell.totalHealing / this.totalHeal) * 100;
	}

	this.totalDps = this.totalDamage / this.duration;
	this.totalHps = this.totalHeal / this.duration;
}
